<?php

namespace app\api\controller;

use app\admin\model\Qrcode;
use app\common\controller\Api;

/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 首页
     *
     */
    public function index()
    {
        $this->success('请求成功');
    }

    public function getInfo(){
        $verify = $this->request->post('verify');
        if (!$verify) {
            $this->error('参数错误', '参数错误');
        }
        $info = Qrcode::where('verify', $verify)->find();
        if ($info) {
            if ($info['qrcode_one']) {
                $info['qrcode_one'] = cdnurl($info['qrcode_one']);
            }

            if ($info['qrcode_two']) {
                $info['qrcode_two'] = cdnurl($info['qrcode_two']);
            }

            if ($info['qrcode_three']) {
                $info['qrcode_three'] = cdnurl($info['qrcode_three']);
            }

            if ($info['background']) {
                $info['background'] = cdnurl($info['background']);
            }
        }
        if (!$info) {
            $this->error('信息不存在', '信息不存在');
        }
        $this->success('请求成功',$info);
    }
}
